package com.gavin.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gavin.service.GeneralInsert;
import com.gavin.service.InsertInterface;

/**
* @ClassName: GeneralServlet
* @Description: 普通的servlet
* @author Gavin Nie  
* @e-mail Nie_ZW@163.com
* @date 2014年7月6日 下午8:21:34
*/
public class GeneralServlet extends HttpServlet
{
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException
	{
		InsertInterface insert = new GeneralInsert();
		 response.setHeader("Content-type", "text/html;charset=UTF-8");
		
		long sum = 0;
		for(int i =1;i<=10;i++){
			Date begin = new Date();
			for(int j =0;j<100;j++){
				insert.insert();
			}
			Date end = new Date();
			long cha = end.getTime()-begin.getTime();
			/*response.getWriter().write("第"+i+"次，使用："+(end.getTime()-begin.getTime())+"毫秒");*/
			sum += cha;
			System.out.println("第"+i+"次，使用："+cha+"毫秒");
		}
		System.out.println("共耗时"+(sum/1000)+"秒");
		
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException
	{
		doGet(request, response);
	}

}
